﻿using System;
namespace Producers.Rr.Xtee.Riik.Ee.Producer.Rr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="RRStorkResponse", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RRStorkResponse))]
    public class RRStorkResponseSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IRRStorkResponse clazz;
        
        public RRStorkResponseSerializer(IRRStorkResponse clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("CertificateInPdf");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "base64Binary");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdBase64Binary(((byte[])(clazz.CertificateInPdf))).ToString());
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="CertificateInPdf") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRStorkResponse>CertificateInPdf");
                }
                clazz.CertificateInPdf = new global::Xtee.Core.Schema.XsdBase64Binary(Reader.ReadElementString("CertificateInPdf")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRStorkResponse>CertificateInPdf", Reader.LocalName);
            }
        }
    }
}
